package com.lingyue.entity.module.def.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.lingyue.entity.groups.Create;
import com.lingyue.entity.groups.Modify;
import com.lingyue.entity.groups.campaign.UpdateUpload;
import com.lingyue.entity.groups.campaign.UpdateValidFlag;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author lizhiyuan
 * @since 2019-12-03
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("campaign")
@ApiModel(value="CampaignEntity对象", description="")
public class CampaignEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @ApiModelProperty(value = "主键", hidden = true)
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(groups = {Modify.class, UpdateUpload.class, UpdateValidFlag.class}, message = "活动信息ID不能为空")
    @TableId(value = "CAM_ID", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "经销商ID")
    @TableField("CAM_DEL_ID")
    private Long delId;

    @ApiModelProperty(value = "线索代码(活动编号)")
    @NotBlank(groups = {Create.class}, message = "活动编号不能为空")
    @Pattern(groups = {Create.class}, message = "活动编号格式错误", regexp = "^[D][A-Z0-9]{7}$")
    @TableField("CAM_CODE")
    private String code;

    @ApiModelProperty(value = "线索名称(活动名称)")
    @NotBlank(groups = {Create.class, Modify.class}, message = "活动名称不能为空")
    @Pattern(groups = {Create.class, Modify.class}, message = "活动名称格式错误",
            regexp = "^[A-Za-z0-9\\——\\，\\。\\/\\、\\-\\”\\“\\'\\,\\.\\u4e00-\\u9fa5]{1,30}$")
    @TableField("CAM_NAME")
    private String name;

    @ApiModelProperty(value = "线索类型(活动类型)")
    @NotNull(groups = {Create.class, Modify.class}, message = "活动类型不能为空")
    @TableField("CAM_TYPE")
    private String type;

    @ApiModelProperty(value = "话术提示")
    @TableField("CAM_KEY_WORD")
    private String keyWord;

    @ApiModelProperty(value = "话术内容")
    @NotBlank(groups = {Create.class, Modify.class}, message = "话术内容不能为空")
    @TableField("CAM_SCRIPT")
    private String script;

    @ApiModelProperty(value = "图片链接")
    @TableField("CAM_IMG_URL")
    private String imgUrl;

    @ApiModelProperty(value = "线索是否上传: Y.是 N.否")
    @NotBlank(groups = {UpdateUpload.class}, message = "线索是否上传不能为空")
    @TableField("CAM_UPLOAD")
    private String upload;

    @ApiModelProperty(value = "来源: NSP/ASSISTANT" , example = "NSP")
    @NotBlank(groups = {Modify.class}, message = "数据来源不能为空")
    @TableField("CAM_DATA_SOURCE")
    private String dataSource;

    @ApiModelProperty(value = "是否通用: Y.通用  N.当前经销商", example = "Y")
    @NotBlank(groups = {Modify.class}, message = "是否通用不能为空")
    @TableField("CAM_DEALER_FLAG")
    private String dealerFlag;

    @ApiModelProperty(value = "是否有效：Y.有效  N.无效", example = "Y")
    @NotBlank(groups = {UpdateValidFlag.class}, message = "线索是否有效不能为空")
    @TableField("CAM_VALID_FLAG")
    private String validFlag;

    @ApiModelProperty(value = "有效天数", example = "10")
    @NotNull(groups = {Create.class, Modify.class}, message = "有效天数不能为空")
    @Min(value = 1)
    @TableField("CAM_VALID_DAYS")
    private Integer validDays;

    @TableField("CAM_CREATE_USER")
    private String createUser;

    @ApiModelProperty(example = "2019-11-27 10:20:45")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @TableField("CAM_CREATE_DATE")
    private LocalDateTime createDate;

    @TableField("CAM_UPDATE_USER")
    private String updateUser;

    @ApiModelProperty(example = "2019-11-27 10:20:45")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @TableField("CAM_UPDATE_DATE")
    private LocalDateTime updateDate;

    @ApiModelProperty(value = "排序规则", example = "DESC")
    @TableField(exist = false)
    private String orderType;


    public static final String CAM_ID = "CAM_ID";

    public static final String CAM_DEL_ID = "CAM_DEL_ID";

    public static final String CAM_CODE = "CAM_CODE";

    public static final String CAM_NAME = "CAM_NAME";

    public static final String CAM_CTP_ID = "CAM_CTP_ID";

    public static final String CAM_KEY_WORD = "CAM_KEY_WORD";

    public static final String CAM_SCRIPT = "CAM_SCRIPT";

    public static final String CAM_IMG_URL = "CAM_IMG_URL";

    public static final String CAM_UPLOAD = "CAM_UPLOAD";

    public static final String CAM_DATA_SOURCE = "CAM_DATA_SOURCE";

    public static final String CAM_DEALER_FLAG = "CAM_DEALER_FLAG";

    public static final String CAM_VALID_FLAG = "CAM_VALID_FLAG";

    public static final String CAM_VALID_DAYS = "CAM_VALID_DAYS";

    public static final String CAM_CREATE_USER = "CAM_CREATE_USER";

    public static final String CAM_CREATE_DATE = "CAM_CREATE_DATE";

    public static final String CAM_UPDATE_USER = "CAM_UPDATE_USER";

    public static final String CAM_UPDATE_DATE = "CAM_UPDATE_DATE";

}
